USE [DTP]
GO

/****** Object:  Table [dbo].[t_AccidentCards]    Script Date: 11/26/2010 09:54:24 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[t_AccidentCards](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[regionCode] [int] NULL,
	[accidentDateTime] [datetime2](7) NULL,
	[operationType] [int] NULL,
	[cardRegistrationNumber] [int] NULL,
	[checksum] [int] NULL,
	[cardReportNumber] [int] NULL,
	[streetName] [int] NULL,
	[streetCategory] [int] NULL,
	[house] [nvarchar](10) NULL,
	[distanceM] [int] NULL,
	[distanceKm] [int] NULL,
	[centerOfPopulationName] [int] NULL,
	[centerOfPopulationStatus] [int] NULL,
	[roadCategory] [int] NULL,
	[region] [int] NULL,
	[roadName] [int] NULL,
	[roadValue] [int] NULL,
	[participentAmmount] [int] NULL,
	[vehicleAmmount] [int] NULL,
	[accidentScheme] [int] NULL,
	[accidentType] [int] NULL,
	[additionalInfo] [nvarchar](1024) NULL,
	[centerStripWidth] [int] NULL,
	[sidewalkWidth] [int] NULL,
	[roadsideWidth] [int] NULL,
	[roadWidth] [int] NULL,
	[engineeringStructure] [int] NULL,
	[planElement] [int] NULL,
	[coverType] [int] NULL,
	[roadState] [int] NULL,
	[lightType] [int] NULL,
	[whetherType] [int] NULL,
	[roadCondition] [int] NULL,
	[Deleted] [bit] NOT NULL,
	[frontPage] [uniqueidentifier] NULL,
	[backPage] [uniqueidentifier] NULL,
 CONSTRAINT [PK_AccidentCards] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_AccidentScheme] FOREIGN KEY([accidentScheme])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_AccidentScheme]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_AccidentType] FOREIGN KEY([accidentType])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_AccidentType]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_backPage] FOREIGN KEY([backPage])
REFERENCES [dbo].[t_Images] ([Id])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_backPage]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_CenterOfPopulationName] FOREIGN KEY([centerOfPopulationName])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_CenterOfPopulationName]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_CenterOfPopulationStatus] FOREIGN KEY([centerOfPopulationStatus])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_CenterOfPopulationStatus]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_CoverType] FOREIGN KEY([coverType])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_CoverType]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_EngineeringStructure] FOREIGN KEY([engineeringStructure])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_EngineeringStructure]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_frontPage] FOREIGN KEY([frontPage])
REFERENCES [dbo].[t_Images] ([Id])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_frontPage]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_LightType] FOREIGN KEY([lightType])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_LightType]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_OperationType] FOREIGN KEY([operationType])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_OperationType]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_PlanElement] FOREIGN KEY([planElement])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_PlanElement]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_Region] FOREIGN KEY([region])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_Region]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_RoadCategory] FOREIGN KEY([roadCategory])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_RoadCategory]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_RoadCondition] FOREIGN KEY([roadCondition])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_RoadCondition]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_RoadName] FOREIGN KEY([roadName])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_RoadName]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_RoadState] FOREIGN KEY([roadState])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_RoadState]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_RoadValue] FOREIGN KEY([roadValue])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_RoadValue]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_StreetCategory] FOREIGN KEY([streetCategory])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_StreetCategory]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_StreetNames] FOREIGN KEY([streetName])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_StreetNames]
GO

ALTER TABLE [dbo].[t_AccidentCards]  WITH CHECK ADD  CONSTRAINT [FK_WhetherType] FOREIGN KEY([whetherType])
REFERENCES [dbo].[t_Dictionary] ([ID])
GO

ALTER TABLE [dbo].[t_AccidentCards] CHECK CONSTRAINT [FK_WhetherType]
GO

ALTER TABLE [dbo].[t_AccidentCards] ADD  DEFAULT ((0)) FOR [Deleted]
GO


